<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     
  
$id=isset($_GET["id"])?$_GET["id"]:"0";
$type=isset($_GET["type"])?$_GET["type"]:"send";
if($type=='send'){//发送通知方可以查看通知阅读情况（只有系统通知可以查看）
    $T->readDB("select A.content,A.time,B.truename as s_name,A.no_flag from sys_notice A left join sys_member B on B.id=A.sender where A.id='".$id."'");
    $accept_html='';
    //被发送通知的人
    $accepter = $T->db->query("select accepter from sys_notice where id='".$id."'")->fetchColumn(0);
    $accepterarr = explode(',', $accepter); 
    $aid='';
    for($i=0;$i<count($accepterarr);$i++){
       $aid.="'".$accepterarr[$i]."',";
    }
    $condition = " and id in (".$aid."'')";
    //已阅读通知的人
    $reader = $T->db->query("select reader from sys_notice where id='".$id."'")->fetchColumn(0);
    if($reader){
        $readerarr = explode(',', $reader);
    }else{
        $readerarr = array();
    }    
    $list = $T->db->query("SELECT id,deptname FROM sys_department order by odx asc");
    foreach ($list as $k => $val) {
        $accept_html .= '<tr>
                          <td>'.$val["deptname"].'</td>
                          <td>';
        $rp = $T->db->query("select id,truename from sys_member where department=".$val['id'].$condition." order by inserttime");
        foreach ($rp as $key => $value) {
            if(in_array($value['id'], $readerarr))$color = 'red';//已读标为红色
            else $color = '#999';
            $accept_html.='<li style="color:'.$color.'">'.$value["truename"].'</li>';
        }
        $accept_html .= '</td></tr>';
    }
    $T->Set("accept_html",$accept_html);
}else{//被通知方只显示通知信息
    $T->readDB("select A.content,A.time,B.truename as s_name from sys_notice_list A left join sys_member B on B.id=A.sender where A.id='".$id."'");
}     
$T->Set("type",$type);
        
$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 